//
//  UIView+Loading.m
//  LoadImageAnimation
//
//  Created by Burn on 2019/3/18.
//  Copyright © 2019 menksoft. All rights reserved.
//

#import "UIView+Loading.h"
#import "LoadAnimation.h"
#import <objc/runtime.h>
@implementation UIView (Loading)

const static char loadingViewKey;


- (void)showLoadingView
{
        self.loadingView = nil;
        LoadAnimation *loadingView = [[LoadAnimation alloc]init];
        [loadingView showInView:self];
        self.loadingView = loadingView;
}
- (void)hideLoadingView
{
    if (self.loadingView) {
        [self.loadingView dismiss];
        self.loadingView = nil;
    }
    
}
- (UIView *)loadingView
{
    return objc_getAssociatedObject(self, &loadingViewKey);
}


- (void)setLoadingView:(UIView *)loadingView{
    objc_setAssociatedObject(self, &loadingViewKey, loadingView, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
@end
